home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / muzsrc1.zip / MUZIKA.H < prev    next >
C/C++ Source or Header  |  1992-07-21  |  12KB  |  368 lines

  1. // **********************************************
  2. // File: MUZIKA.H
  3. // The MUZIKA.H file contains global definitions
  4. // concerning all modules of the software.
  5.  
  6. #ifndef __MUZIKA_H
  7. #define __MUZIKA_H
  8.  
  9. #include <windows.h>
  10. #include <object.h>
  11. #include <array.h>
  12.  
  13. // **********************************************
  14. // Constant definitions
  15.  
  16. const EDITMODESTRINGS = 0x0;
  17.  
  18. const MELODY = 0;
  19. const PART = 1;
  20. const STAFF = 2;
  21. const POINTOBJECT = 3;
  22. const CONTINUOUSOBJECT = 4;
  23.  
  24. const INSTAFF = 0;
  25. const COMMONMULTIPLE = 1;
  26. const ABOVESTAFF = 2;
  27. const ABOVEMULTIPLE = 3;
  28. const BELOWSTAFF = 4;
  29. const BELOWMULTIPLE = 5;
  30. const ONEPERSTAFF = 0x80;
  31.  
  32. const FULLDURATION = 0x30;
  33. const HALFDURATION = 0x18;
  34. const QUARTERDURATION = 0x0C;
  35. const EIGHTHDURATION = 0x06;
  36. const SIXTEENTHDURATION = 0x03;
  37. const KEYSOL = 0;
  38. const KEYFA = 1;
  39. const BEATC = 0;
  40. const BEATCBAR = 1;
  41. const BEAT28 = 2;
  42. const BEAT24 = 3;
  43. const BEAT38 = 4;
  44. const BEAT34 = 5;
  45. const BEAT48 = 6;
  46. const BEAT44 = 7;
  47. const BEAT68 = 8;
  48. const BAR = 0;
  49. const DOUBLEBAR = 1;
  50. const STARTBAR = 2;
  51. const ENDBAR = 3;
  52. const FORTE = 1;
  53. const FORTISSIMO = 2;
  54. const PIANO = -1;
  55. const PIANISSIMO = -2;
  56. const CRESCENDO = 1;
  57. const DIMINUENDO = -1;
  58.  
  59. typedef enum {PENCIL, ERASER, HAND} EDITMODE;
  60. typedef enum {SINGLESTAFF, FIRSTSTAFF, MIDSTAFF, LASTSTAFF} STAFFLOC;
  61.  
  62. const MAXPARTNAME = 10;
  63. const MAXMULTIPLICITY = 4;
  64. const MAXTEXT = 15;
  65.  
  66. // **********************************************
  67. // Definitions of global variables
  68.  
  69. extern HANDLE hInst;              // Instance handle (MAIN.CPP)
  70. extern HWND hMainWnd;             // Main window handle (MAIN.CPP)
  71. extern HMENU hMainMenu;           // Main menu handle (MAIN.CPP)
  72. extern BOOL melodyExists;         // True if melody exists (DATABASE.CPP)
  73. extern HWND hEditWnd;             // Edit window handle (DISPLAY.CPP)
  74. extern HCURSOR hEditCursor;       // Edit window cursor (DISPLAY.CPP)
  75. extern int currStaffHeight;       // Height of current staff (DISPLAY.CPP)
  76. extern STAFFLOC staffLoc;         // Current staff logical location (DISPLAY.CPP)
  77. extern int staffX, staffY;        // Current staff coordinates (DISPLAY.CPP)
  78. extern int scoreMultiplicity;     // Score staff multiplicity (DISPLAY.CPP)
  79. extern int scoreStaves;           // Number of staves on score (DISPLAY.CPP)
  80. extern int scoreFirstStaff;       // Topmost staff on score display (DISPLAY.CPP)
  81. extern int scoreFirstPart;        // Topmost part on score display (DISPLAY.CPP)
  82. extern char programTitle[];       // Caption title of the program window (FILE.CPP)
  83. extern BOOL melodyModified;       // True if melody has been modified (FILE.CPP)
  84. extern int markBeginStaff;        // Staff where mark begins (BLOCK.CPP)
  85. extern int markBeginX;            // X-coordinate of mark begin (BLOCK.CPP)
  86. extern int markEndStaff;          // Staff where mark ends (BLOCK.CPP)
  87. extern int markEndX;              // X-coordinate of mark end (BLOCK.CPP)
  88. extern BOOL scoreDisplay;         // True if displaying all parts (LAYOUT.CPP)
  89. extern int displayedPart;         // Currently displayed part (LAYOUT.CPP)
  90. extern unsigned pixelsPerStaff;   // Staff height in pixels (LAYOUT.CPP)
  91. extern unsigned pixelsPerObject;  // Object width in pixels (LAYOUT.CPP)
  92. extern int activeSymbolSet;       // Current symbol set (SYMBOL.CPP)
  93.  
  94. // **********************************************
  95. // Definitions of class types
  96.  
  97. class IndexedList : public Array {
  98.   public:
  99.     IndexedList() :
  100.       Array(0, 0, 1) {}
  101.     IndexedList(int anUpper, int aLower = 0, int aDelta = 1) :
  102.       Array(anUpper, aLower, aDelta) {}
  103.     int number() {return itemsInContainer;}
  104.     void insertAt(Object &, int);
  105.     void detachAt(int);
  106.     void destroyAt(int);
  107.     void printOn(ostream &) const;
  108. };
  109.  
  110. class MelodyParameters {
  111.   unsigned staffWidth;
  112.  
  113.   protected:
  114.     BOOL LoadFrom(istream &, void (*)());
  115.     void printOn(ostream &);
  116.  
  117.   public:
  118.     unsigned GetStaffWidth() {return staffWidth;}
  119.     void SetStaffWidth(unsigned newWidth) {staffWidth = newWidth;}
  120. };
  121.  
  122. class Melody : public MelodyParameters {
  123.   public:
  124.     IndexedList part;
  125.  
  126.     Melody();
  127.     ~Melody();
  128.     BOOL LoadFrom(istream &, void (*)());
  129.     void printOn(ostream &);
  130. };
  131.  
  132. extern Melody melody;             // The melody database (DATABASE.CPP)
  133.  
  134. class PartParameters {
  135.   protected:
  136.     char _name[MAXPARTNAME+1];
  137.     int _multiplicity;
  138.     unsigned editYMin;
  139.  
  140.     BOOL LoadFrom(istream &, void (*)());
  141.     void printOn(ostream &);
  142.  
  143.   public:
  144.     char *name() {return _name;}
  145.     int &multiplicity() {return _multiplicity;}
  146.     void SetPartY(unsigned Y) {editYMin = Y;}
  147.     unsigned GetPartY() {return editYMin;}
  148. };
  149.  
  150. class Part : public Object, public PartParameters {
  151.   public:
  152.     IndexedList staff;
  153.  
  154.     Part();
  155.     Part(const char *, int);
  156.     ~Part();
  157.     virtual classType isA() const {return PART;}
  158.     virtual char *nameOf() const {return "Part";}
  159.     virtual hashValueType hashValue() const {return 0;}
  160.     virtual int isEqual(const Object &obj) const
  161.       {return (obj.isA() == PART);}
  162.     BOOL LoadFrom(istream &, void (*)());
  163.     virtual void printOn(ostream &) const;
  164. };
  165.  
  166. class StaffParameters {
  167.   protected:
  168.     unsigned _X, _Y, _width;
  169.  
  170.     BOOL LoadFrom(istream &, void (*)());
  171.     void printOn(ostream &);
  172.  
  173.   public:
  174.     unsigned &X() {return _X;}
  175.     unsigned &Y() {return _Y;}
  176.     unsigned &width() {return _width;}
  177. };
  178.  
  179. class Staff : public Object, public StaffParameters {
  180.   public:
  181.     IndexedList pointObject;
  182.     IndexedList continuousObject;
  183.  
  184.     Staff();
  185.     Staff(int);
  186.     ~Staff();
  187.     BOOL Draw(HDC, int, BOOL);
  188.     virtual classType isA() const {return STAFF;}
  189.     virtual char *nameOf() const {return "Staff";}
  190.     virtual hashValueType hashValue() const {return 0;}
  191.     virtual int isEqual(const Object &obj) const
  192.       {return (obj.isA() == STAFF);}
  193.     BOOL LoadFrom(istream &, void (*)());
  194.     virtual void printOn(ostream &) const;
  195. };
  196.  
  197. // **********************************************
  198. // The MusicalObject class is the base class from which all musical
  199. // object types are derived. It defines a few virtual functions that
  200. // should be given own versions in the derived classes.
  201. // The tree starting at MusicalObject divides into two main subtrees:
  202. // point objects (derived from PointObject), who have only one (if at all)
  203. // X coordinate, and continuous objects (derived from ContinuousObject),
  204. // which have a starting and ending X coordinate.
  205.  
  206. class MusicalObject : public Object {
  207.   protected:
  208.     int _location;
  209.  
  210.   public:
  211.     int &location() {return _location;}
  212.     virtual void Draw(HDC) = 0;
  213.     virtual classType isA() const = 0;
  214.     virtual char *nameOf() const = 0;
  215.     virtual hashValueType hashValue() const = 0;
  216.     virtual int isEqual(const Object &) const = 0;
  217.     virtual void printOn(ostream &) const = 0;
  218.     virtual void clipOn(void far *&) const = 0;
  219. };
  220.  
  221. class PointObject : public MusicalObject {
  222.   protected:
  223.     int _X;
  224.  
  225.   public:
  226.     int &X() {return _X;}
  227.     virtual void Draw(HDC) = 0;
  228.     virtual void Format(int &X) {_X = X;}
  229.     virtual int Width() {return pixelsPerObject;}
  230.     virtual void MIDIPlay(ostream &, int) {}
  231.     virtual int Duration() {return 0;}
  232.     virtual classType isA() const {return POINTOBJECT;}
  233.     virtual char *nameOf() const {return "PointObject";}
  234.     virtual hashValueType hashValue() const {return 0;}
  235.     virtual int isEqual(const Object &obj) const
  236.       {return (obj.isA() == POINTOBJECT);}
  237.     virtual void printOn(ostream &) const = 0;
  238.     virtual void clipOn(void far *&) const = 0;
  239. };
  240.  
  241. class ContinuousObject : public MusicalObject {
  242.   protected:
  243.     int _Xleft, _Xright;
  244.  
  245.   public:
  246.     int &Xleft() {return _Xleft;}
  247.     int &Xright() {return _Xright;}
  248.     virtual void Draw(HDC) = 0;
  249.     virtual void FormatLeft(int &Xleft) {_Xleft = Xleft;}
  250.     virtual void FormatRight(int &Xright) {_Xright = Xright;}
  251.     virtual classType isA() const {return CONTINUOUSOBJECT;}
  252.     virtual char *nameOf() const {return "ContinuousObject";}
  253.     virtual hashValueType hashValue() const {return 0;}
  254.     virtual int isEqual(const Object &obj) const
  255.       {return (obj.isA() == CONTINUOUSOBJECT);}
  256.     virtual void printOn(ostream &) const = 0;
  257.     virtual void clipOn(void far *&) const = 0;
  258. };
  259.  
  260. // **********************************************
  261. // The SymbolClass class is a generic type
  262. // from which symbol class types are derived.
  263.  
  264. class SymbolClass {
  265.   protected:
  266.     int symbolID;
  267.     char symbolType;
  268.  
  269.   public:
  270.     int GetID() {return symbolID;}
  271.     char GetType() {return symbolType;}
  272.     int BitmapName(LPSTR, int);
  273.     void DrawSymbol(HDC, HDC, BOOL);
  274.     virtual MusicalObject *CreateObject(int, int, int) = 0;
  275. };
  276.  
  277. extern class NullSymbol : virtual public SymbolClass {
  278.   public:
  279.     NullSymbol();
  280.     void DrawSymbol(HDC, int);
  281. #pragma argsused
  282.     virtual MusicalObject *CreateObject(int staff, int X, int Y) {return NULL;}
  283. } nullSymbol;
  284.  
  285. extern SymbolClass *symbolArray[]; // The symbol array (SYMCLASS.CPP)
  286.  
  287. // **********************************************
  288. // Prototypes of functions interfaced among the modules
  289. // follow. The functions are divided according to their place of definition.
  290.  
  291. // Main window functions (MAIN.CPP)
  292. void InitMain(HANDLE, HANDLE, int);
  293. void InitMainFirst(HANDLE);
  294. void InitMainAdded(HANDLE, HANDLE);
  295. void InitMainEvery(HANDLE, int);
  296. void CloseMain(HANDLE);
  297. long FAR PASCAL _export MainWindowProc(HWND, unsigned, WORD, LONG);
  298. void PaintMainWindow(HWND);
  299.  
  300. // Display module functions (DISPLAY.CPP)
  301. #define WidthRound(x) ((x)/pixelsPerObject*pixelsPerObject+pixelsPerObject/2)
  302. void RegisterEditClass(HANDLE);
  303. void CreateEditWindow(HANDLE);
  304. long FAR PASCAL _export EditWindowProc(HWND, unsigned, WORD, LONG);
  305. void PaintEditWindow(HWND);
  306.  
  307. // Edit module functions (EDIT.CPP)
  308. int IdentifyStaff(IndexedList &, unsigned);
  309. void NewMultipleStaff(int);
  310. void DeleteMultipleStaff(int);
  311. void NewPointObject(SymbolClass *, int, int);
  312. void NewContinuousObject(SymbolClass *, int, int, int);
  313. void DeleteMusicalObject(int, int);
  314. void MoveStaff(int, int);
  315. void MoveMusicalObject(int, int, int, int);
  316.  
  317. // Musical text reformatting functions (FORMAT.CPP)
  318. int FindMinDuration(int *, int);
  319. void FormatEntirePart();
  320.  
  321. // MIDI file creation functions (MIDI.CPP)
  322. void CreateMIDIFile(ostream &);
  323.  
  324. // Menu processing functions (MENU.CPP)
  325. BOOL ProcessMenu(WORD);
  326. void InitializeMenu(BOOL);
  327.  
  328. // File dialog box functions (FILE.CPP)
  329. BOOL AskSave();
  330. BOOL FAR PASCAL _export DialogNew(HWND, unsigned, WORD, LONG);
  331. BOOL FAR PASCAL _export DialogOpen(HWND, unsigned, WORD, LONG);
  332. BOOL Save();
  333. BOOL FAR PASCAL _export DialogSaveAs(HWND, unsigned, WORD, LONG);
  334. BOOL FAR PASCAL _export DialogCreateMIDI(HWND, unsigned, WORD, LONG);
  335.  
  336. // Printing functions (PRINT.CPP)
  337. void PrintEditWindow();
  338.  
  339. // Block operation functions (BLOCK.CPP)
  340. void MarkBlock(int, int, int, int);
  341. void UnmarkBlock();
  342. void CutBlock();
  343. void CopyBlock();
  344. void PasteBlock(int, int);
  345.  
  346. // Layout dialog box functions (LAYOUT.CPP)
  347. BOOL FAR PASCAL _export DialogParts(HWND, unsigned, WORD, LONG);
  348. BOOL FAR PASCAL _export DialogPage(HWND, unsigned, WORD, LONG);
  349. BOOL FAR PASCAL _export DialogNewPart(HWND, unsigned, WORD, LONG);
  350.  
  351. // "About..." dialog box function (ABOUT.CPP)
  352. BOOL FAR PASCAL _export DialogAbout(HWND, unsigned, WORD, LONG);
  353.  
  354. // Symbol functions (SYMBOL.CPP)
  355. void DisplayEditModeSymbols(HDC);
  356. BOOL IdentifyEditModeSymbol(DWORD);
  357. void RefreshSymbols(HDC);
  358. SymbolClass *IdentifySymbol(DWORD);
  359. void SelectSymbolSet(int);
  360. int GetActiveSymbol();
  361. SymbolClass *GetCurrentSymbol();
  362.  
  363. // Object library functions (OBJCLASS.CPP)
  364. MusicalObject *LoadObject(istream &, void (*)(), int *);
  365. MusicalObject *PasteObject(void far *&, int *);
  366.  
  367. #endif
  368.